<?php
class TempnhiemvunvsController extends AppController {

	var $name = 'Tempnhiemvunvs';
	var $helpers = array('Html', 'Form');

	function index() {
		$this->Tempnhiemvunv->recursive = 0;
		$this->set('tempnhiemvunvs', $this->paginate());
	}

	function view($id = null) {
		if (!$id) {
			$this->Session->setFlash(__('Invalid Tempnhiemvunv.', true));
			$this->redirect(array('action'=>'index'));
		}
		$this->set('tempnhiemvunv', $this->Tempnhiemvunv->read(null, $id));
	}

	function add() {
		if (!empty($this->data)) {
			$this->Tempnhiemvunv->create();
			if ($this->Tempnhiemvunv->save($this->data)) {
				$this->Session->setFlash(__('The Tempnhiemvunv has been saved', true));
				$this->redirect(array('action'=>'index'));
			} else {
				$this->Session->setFlash(__('The Tempnhiemvunv could not be saved. Please, try again.', true));
			}
		}
		$nhanviens = $this->Tempnhiemvunv->Nhanvien->find('list');
		$kehoaches = $this->Tempnhiemvunv->Kehoach->find('list');
		$this->set(compact('nhanviens', 'kehoaches'));
	}

	function edit($id = null) {
		if (!$id && empty($this->data)) {
			$this->Session->setFlash(__('Invalid Tempnhiemvunv', true));
			$this->redirect(array('action'=>'index'));
		}
		if (!empty($this->data)) {
			if ($this->Tempnhiemvunv->save($this->data)) {
				$this->Session->setFlash(__('The Tempnhiemvunv has been saved', true));
				$this->redirect(array('action'=>'index'));
			} else {
				$this->Session->setFlash(__('The Tempnhiemvunv could not be saved. Please, try again.', true));
			}
		}
		if (empty($this->data)) {
			$this->data = $this->Tempnhiemvunv->read(null, $id);
		}
		$nhanviens = $this->Tempnhiemvunv->Nhanvien->find('list');
		$kehoaches = $this->Tempnhiemvunv->Kehoach->find('list');
		$this->set(compact('nhanviens','kehoaches'));
	}

	function delete($id = null) {
		if (!$id) {
			$this->Session->setFlash(__('Invalid id for Tempnhiemvunv', true));
			$this->redirect(array('action'=>'index'));
		}
		if ($this->Tempnhiemvunv->del($id)) {
			$this->Session->setFlash(__('Tempnhiemvunv deleted', true));
			$this->redirect(array('action'=>'index'));
		}
	}

}
?>